<?php


namespace app\api\community\utils;


use ipip\db\City;

class IpUtil
{

    public ?object $city = null;

    public function __construct()
    {
        $this->city = new City(app() -> getRootPath().'bin/ipipfree.ipdb');
    }

    public function get_ipv4_find(string $ip, $lang = 'CN'): ?array
    {
        return $this->city -> find($ip, $lang);
    }

    public function get_ipv4_find_map(string $ip, $lang = 'CN'): ?array
    {
        return $this->city -> findMap($ip, $lang);
    }

    public function get_ipv4_find_info(string $ip, $lang = 'CN'): ?\ipip\db\CityInfo
    {
        return $this->city -> findInfo($ip, $lang);
    }

}